use apikit::{
    HandlerDef,
    rpc::{DutyClient, ServerAddressManager, http_client::HttpClient},
};
use demo_api::api::{prelude::Json, prelude::Query, user::add_user::*};
use reqwest::{Client, Method};

#[tokio::test]
async fn a() {
    pub struct ServiceManager;
    impl ServerAddressManager for ServiceManager {
        fn get_server_addr(&self, _name: &str) -> &str {
            "http://localhost"
        }
    }
    let path = HandleDef_::path();
    println!("{path}");

    let client = Client::new();
    let result = <Client as HttpClient>::call_service::<(), String>(
        &client,
        "http://localhost/api/file-user/online-query",
        Method::POST,
        (),
    )
    .await;
    println!("{result:?}");

    let clent = HandleClient::new(Client::new(), ServiceManager);
    let result = clent
        ._handle(
            Query(RequestData { id: 12, sex: 1 }),
            Json(RequestData { id: 23, sex: 1 }),
        )
        .await;
    match result {
        Ok(value) => {
            println!("{:?}", value.data);
        }
        Err(e) => {
            println!("{e:?}");
        }
    }
}
